package hz.mobileproject.pda.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

import hz.mobileproject.pda.R;
import hz.mobileproject.pda.entity.response.Rp_eduType;
import hz.mobileproject.pda.ui.base.BaseCustomAdapter;

/**
 * Created by Lc on 2017/12/19.
 */

public class EduTalkTrackDialogAdapter extends BaseCustomAdapter<Rp_eduType,EduTalkTrackDialogAdapter.ViewHolder> {

    public EduTalkTrackDialogAdapter(Context mContext, List<Rp_eduType> list) {
        super(mContext, list);
    }

    @Override
    protected int bindView() {
        return R.layout.item_edu_check_box;
    }

    @Override
    protected ViewHolder createViewHolder() {
        return new ViewHolder();
    }

    @Override
    protected void bindData(final int position, View convertView, ViewHolder viewHolder) {
        if (Rp_eduType.DEFAULT_CHECK.equals(mList.get(position).getDisplay_value())) {
            viewHolder.checkBox.setEnabled(false);
            mList.get(position).setChecked(true);
        }
        viewHolder.checkBox.setChecked(mList.get(position).isChecked());
        viewHolder.checkBox.setText(mList.get(position).getDisplay_field());
        viewHolder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mList.get(position).setChecked(isChecked);
            }
        });
    }

    class ViewHolder {
        @ViewInject(R.id.checkBox)
        CheckBox checkBox;
    }
}
